package com.zhentao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhentao.UserInfoThreadLocalUtil;
import com.zhentao.mapper.UserAddressMapper;
import com.zhentao.model.entity.user.UserAddress;
import com.zhentao.model.entity.user.UserInfo;
import com.zhentao.service.UserAddressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@SuppressWarnings({"unchecked", "rawtypes"})
public class UserAddressServiceImpl implements UserAddressService {
    @Resource
    private UserAddressMapper userAddressMapper;
    //查询用户地址--订单
    @Override
    public UserAddress getById(Long id) {
//        return userAddressMapper.getById(id);
        QueryWrapper<UserAddress> queryWrapper=new QueryWrapper<>();
        queryWrapper.lambda().eq(UserAddress::getId,id);
       return  this.userAddressMapper.selectOne(queryWrapper);
    }

    @Override
    public List<UserAddress> findUserAddressList() {
//        UserInfo user = UserInfoThreadLocalUtil.getUser();
        return userAddressMapper.findByUserId(1l);
    }
}
